home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: What is wrong with this code? (BC45)
- Date: Sun, 28 Jan 1996 23:10:50 GMT
- Organization: Netcom
- Message-ID: <310c01e6.172032896@nntp.ix.netcom.com>
- References: <yMOCxg2yqvDD083yn@iaccess.za> <4efqt4$4dd@soap.news.pipex.net>
- NNTP-Posting-Host: ix-dc16-21.ix.netcom.com
- X-NETCOM-Date: Sun Jan 28 3:10:27 PM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- Russell Stather <hj11@dial.pipex.com> wrote:
-
- > You will get this error if Fred and Mark are global variables as the value
- > of Fred is not known at compile time. If Fred and Mark are local variables
- > to a function then this will be ok.
- >
- > If you do want them to be global then you can get this to work by defining
- > them as const.
-
- This is true in C, but not in C++. In C++ initializers of globals may
- be arbitrary expressions.
-
- Note: since Russell's post did not include the original by Vince Risi,
- I reproduce it below:
-
- > Why would I get an illegal initialization from this code?
-
- > typedef char * pchar;
- > pchar Fred = "This is a default value";
- > pchar Mark = Fred; // <------ ????
-
- > Is this a BC45 bug?
-
-
- Michael M Rubenstein
-